.PHONY: all clean

CC		:= gcc
CCFLAGS := -I../

OBJCOPY := objcopy
OBJDUMP := objdump

all: boot_s0 boot_s1

boot_s0.o: boot_s0.S
	${CC} ${CCFLAGS} $< -c -o$@

boot_s1.o: boot_s1.S
	${CC} ${CCFLAGS} $< -c -o$@

main.o: main.c
	${CC} ${CCFLAGS} $< -c -o$@

boot_s0: boot_s0.o
# the entry point is ``start''
	${LD} -N -e main -Ttext 0x7c00 -o $@.out $^
#	${OBJDUMP} -S $@.out >$@.asm
	${OBJCOPY} -S -Obinary $@.out $@
	./sign.pl $@

boot_s1: boot_s1.o main.o
	${LD} -N -e main -Ttext 0x8000 -o $@.out $^
#	${OBJDUMP} -S $@.out >$@.asm
	${OBJCOPY} -S -Obinary $@.out $@

clean:
	-rm *.out
	-rm boot.img boot_s0 boot_s1
	-rm *.o
